# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Alfredo Palhares <masterkorp@masterkorp.net>
# Contributor: Jochen Schalanda <jochen+aur@schalanda.name>

_gemname=power_assert
pkgname="ruby-${_gemname}"
pkgver=2.0.2
pkgrel=1
pkgdesc='Power Assert for Ruby'
arch=('any')
url="https://github.com/ruby/${_gemname}"
license=('custom:BSDL')
depends=('ruby')
makedepends=('ruby-rdoc' 'ruby-rake')
checkdepends=('ruby-test-unit')
options=('!emptydirs')
source=("${url}/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('8c1e40cdd1dc8a00bddf699af3a55c08e5f2f5ba4c0ff5d1fffe64300385b1558f4e4653ca7b5a755c2ffc058bea005322708b43117911e4bfe84783eee5f537')

prepare() {
  cd "${_gemname}-${pkgver}"
  sed --in-place 's|`git ls-files -z`|`find . -print0`|' "${_gemname}.gemspec"
  sed --in-place '/bundler/d' Rakefile
}

build() {
  cd "${_gemname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${_gemname}-${pkgver}"
  rake test
}

package() {
  cd "${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  rm -rf "${pkgdir}/${_gemdir}/cache"
  rm -rf "${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/.github"

  install -Dm 644 README.md  -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 BSDL COPYING LEGAL -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
